﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:Framework.UI.Controls"
                    xmlns:params="http://schemas.codeplex.com/elysium/params">
    <ResourceDictionary.MergedDictionaries>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Brush.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type controls:Icon}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Display"/>
        <Setter Property="TextOptions.TextRenderingMode" Value="ClearType"/>
        <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled"/>
        <Setter Property="Background" Value="{StaticResource TransparentBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource TransparentBrush}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="FontStretch" Value="Medium"/>
        <Setter Property="FontStyle" Value="Normal"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="Foreground" Value="{StaticResource LowlightBrush}"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverlayBackground" Value="{StaticResource ContrastBrush}"/>
        <Setter Property="OverlayBorderBrush" Value="{Binding Path=Foreground, RelativeSource={RelativeSource Self}}"/>
        <Setter Property="OverlayBorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldThickness), Mode=OneWay}"/>
        <Setter Property="OverlayMargin" Value="-2"/>
        <Setter Property="OverlayPadding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldThickness), Mode=OneWay}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:Icon}">
                    <Border Background="{Binding Path=Background, RelativeSource={RelativeSource AncestorType={x:Type controls:Icon}}}"
                            BorderBrush="{Binding Path=BorderBrush, RelativeSource={RelativeSource AncestorType={x:Type controls:Icon}}}" 
                            BorderThickness="{Binding Path=BorderThickness, RelativeSource={RelativeSource AncestorType={x:Type controls:Icon}}}"
                            SnapsToDevicePixels="{Binding Path=SnapsToDevicePixels, RelativeSource={RelativeSource AncestorType={x:Type controls:Icon}}}">
                        <Grid>
                            <ContentPresenter/>
                            <Grid x:Name="PART_Overlay"
                                      HorizontalAlignment="{TemplateBinding OverlayHorizontalAlignment}"
                                      Margin="{TemplateBinding OverlayMargin}"
                                      VerticalAlignment="{TemplateBinding OverlayVerticalAlignment}"
                                      Visibility="Collapsed">
                                <Ellipse x:Name="PART_OverlayBackground" 
                                             Fill="{TemplateBinding OverlayBackground}"
                                             Stroke="{TemplateBinding OverlayBorderBrush}"
                                             StrokeThickness="{TemplateBinding OverlayBorderBrush}"/>
                                <controls:Icon x:Name="PART_OverlayIcon" 
                                                   Height="{TemplateBinding OverlayHeight}"
                                                   HorizontalAlignment="Center"
                                                   Margin="{TemplateBinding OverlayPadding}"
                                                   Size="Custom"
                                                   Style="{TemplateBinding OverlayStyle}"
                                                   VerticalAlignment="Center"
                                                   Width="{TemplateBinding OverlayWidth}"/>
                            </Grid>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsOverlayVisible" Value="True">
                            <Setter Property="Visibility" TargetName="PART_Overlay" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="Size" Value="Small">
                            <Setter Property="FontSize" Value="16"/>
                            <Setter Property="Height" Value="16"/>
                            <Setter Property="Width" Value="16"/>
                        </Trigger>
                        <Trigger Property="Size" Value="Medium">
                            <Setter Property="FontSize" Value="24"/>
                            <Setter Property="Height" Value="24"/>
                            <Setter Property="Width" Value="24"/>
                        </Trigger>
                        <Trigger Property="Size" Value="Large">
                            <Setter Property="FontSize" Value="32"/>
                            <Setter Property="Height" Value="32"/>
                            <Setter Property="Width" Value="32"/>
                        </Trigger>
                        <Trigger Property="Size" Value="VeryLarge">
                            <Setter Property="FontSize" Value="64"/>
                            <Setter Property="Height" Value="64"/>
                            <Setter Property="Width" Value="64"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{StaticResource DisabledBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="GeometryBaseIconStyle" BasedOn="{StaticResource {x:Type controls:Icon}}" TargetType="{x:Type controls:Icon}">
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Path Data="{Binding}"
                          Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type controls:Icon}}}" 
                          Stretch="{Binding Path=Stretch, RelativeSource={RelativeSource AncestorType={x:Type controls:Icon}}}"/>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TextBaseIconStyle" BasedOn="{StaticResource {x:Type controls:Icon}}" TargetType="{x:Type controls:Icon}">
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <TextBlock FontSize="{Binding Path=FontSize, RelativeSource={RelativeSource AncestorType={x:Type controls:Icon}}}" 
                               FontStretch="{Binding Path=FontStretch, RelativeSource={RelativeSource AncestorType={x:Type controls:Icon}}}"
                               FontStyle="{Binding Path=FontStyle, RelativeSource={RelativeSource AncestorType={x:Type controls:Icon}}}"
                               FontWeight="{Binding Path=FontWeight, RelativeSource={RelativeSource AncestorType={x:Type controls:Icon}}}"
                               Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type controls:Icon}}}" 
                               Text="{Binding}"
                               TextAlignment="Center"
                               VerticalAlignment="Center"/>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ImageBaseIconStyle" BasedOn="{StaticResource {x:Type controls:Icon}}" TargetType="{x:Type controls:Icon}">
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Grid Background="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type controls:Icon}}}">
                        <Grid.OpacityMask>
                            <VisualBrush>
                                <VisualBrush.Visual>
                                    <Image Source="{Binding}" 
                                           Stretch="{Binding Path=Stretch, RelativeSource={RelativeSource AncestorType={x:Type controls:Icon}}}"/>
                                </VisualBrush.Visual>
                            </VisualBrush>
                        </Grid.OpacityMask>
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
